import request from "./index";

/**
 *
 * @param {*} page
 * @param {*} limit
 * @param {*} moduleId
 * @param {*} moduleName
 * @param {*} reportNo
 * @returns
 */
export function pqsstartWkInfo_query_page(params) {
    return request({
        url: `/pqsstartWkInfo_query_page`,
        method: "get",
        params,
        headers: {
            "Content-Type": "application/json;charset=utf-8",
        },
    });
}

export function getPdfInfo(kid) {
    return request({
        url: `/getPdfInfo`,
        method: "get",
        params: { kid },
        headers: {
            "Content-Type": "application/json;charset=utf-8",
        },
    });
}

export function pqsprojTableData_query_page(joinId) {
    return request({
        url: `/pqsprojTableData_query_page`,
        method: "get",
        params: { joinId },
        headers: {
            "Content-Type": "application/json;charset=utf-8",
        },
    });
}

//审核流程

export function findCustomInfo(businesskey) {
    return request({
        url: `/workflow/findCustomInfo`,
        method: "get",
        params: { businesskey },
        headers: {
            "Content-Type": "application/json;charset=utf-8",
        },
    });
}

export function findHistoryProcess(businesskey) {
    return request({
        url: `/workflow/findHistoryProcess`,
        method: "get",
        params: { businesskey },
        headers: {
            "Content-Type": "application/json;charset=utf-8",
        },
    });
}

export function findCurrentProcess(businesskey) {
    return request({
        url: `/workflow/findCurrentProcess`,
        method: "get",
        params: { businesskey },
        headers: {
            "Content-Type": "application/json;charset=utf-8",
        },
    });
}

export function findPreviewProcess(applyUserId, processDefinitionKey, startNodeId, businesskey) {
    return request({
        url: `/workflow/findPreviewProcess`,
        method: "get",
        params: {
            applyUserId,
            processDefinitionKey,
            startNodeId,
            businesskey,
        },
        headers: {
            "Content-Type": "application/json;charset=utf-8",
        },
    });
}

//详情数据
export function pqsstartWkInfo_query_one(kid) {
    return request({
        url: `/pqsstartWkInfo_query_one`,
        method: "get",
        params: {
            kid,
        },
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
    });
}

/**
 * 审核
 * @param {*} data {assignee, businesskey, reson, userSignDate, sessionId, nodeId, formType, chkFlag, nextUserIds}
 * @returns
 */
export function chk(data) {
    return request({
        url: `/pqsstartWkInfo/chk`,
        method: "post",
        data,
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
    });
}

// 退回
export function forceBack(data) {
    return request({
        url: `/pqsstartWkInfo_edit`,
        method: "post",
        data,
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
    });
}


// 撤回
export function backout(kid) {
    return request({
        url: `/pqsstartWkInfo/discommit`,
        method: "post",
        data: {
            businesskey: kid
        },
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
    });
}

export function delData(kid) {
    return request({
        url: `pqsstartWkInfo_delete_one`,
        method: "post",
        data: { kid },
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
    });
}

/**
 * 下载文件流
 * 
 * 参数：{ 
    必传参数：
    dbName=gpmspqs
    recordId=对应业务数据的kid
    可选参数：
    fileTitle=需要下载出来的文件名，不传就默认id为文件名
}
 * @param {*} recordId 
 * @param {*} fileTitle 
 * @returns 
 */
export function downloadPdf(recordId, fileTitle) {
    return request({
        url: `/wpfile/downloadPdf`,
        method: "get",
        params: { dbName: "gpmspqs", recordId, fileTitle },
        headers: {
            "Content-Type": "application/x-www-form-urlencoded",
        },
        responseType: "blob",
    });
}
